//
//  HNTeacgerEvaluateDetailModel.m
//  BestLearning
//
//  Created by 星道 on 17/6/3.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HNTeacgerEvaluateDetailModel.h"

@implementation HNTeacgerEvaluateDetailModel

- (instancetype)init_HNObjectForKeys:(NSDictionary *)Dict
{
    self = [super init];
    if (self)
    {
        self.commentArr = [Dict[@"comment"] componentsSeparatedByString:@","];
        [self setValuesForKeysWithDictionary:Dict];
    }
    return self;
}


- (void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"u2"])
    {
        self.username = value[@"username"];
        self.avatar = value[@"avatar"];
        self.petName = value[@"petName"];
    }
    else if ([key isEqualToString:@"personalF"])
    {
        self.personalF = value[@"path"];
        if ([self.personalF isKindOfClass:[NSNull class]])
        {
            self.personalF = @"";
        }
    }
    else if ([key isEqualToString:@"slist"])
    {
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            NSMutableDictionary *dict = [(NSDictionary *)obj mutableCopy];
            if ([dict[@"type"] isEqualToNumber:@1]) {
                
                [self.HaoXiGuan_Arr addObject:dict];
            } else if ([dict[@"type"] isEqualToNumber:@2]) {
                
                [self.HaoChengJi_Arr addObject:dict];
            } else {
                
                [self.HaoSuYang_Arr addObject:dict];
            }
            [self.commentArr enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                NSString *ID = [dict[@"id"] stringValue];
                NSString *XX = [[obj componentsSeparatedByString:@"-"] firstObject];
                if ([ID isEqualToString:XX]) {
                    NSString *CC = [[obj componentsSeparatedByString:@"-"] lastObject];
                    [dict setObject:CC forKey:@"comment"];
                    *stop = YES;
                }
            }];
        }];
    }
    else if ([key isEqualToString:@"videos"])
    {
        for (NSDictionary *Dict in value) {
            [self.Videos_Arr addObject:Dict];
        }
    }
    
    else if ([key isEqualToString:@"imgFs"])
    {
        for (NSDictionary *Dict in value)
        {
            [self.ImgF_Arr addObject:Dict[@"path"]];
        }
            
    }
    else if ([key isEqualToString:@"commonF"])
    {
        self.commonF = value[@"path"];
        if ([self.commonF isKindOfClass:[NSNull class]])
        {
            self.commonF = @"";
        }
    }
    else if ([key isEqualToString:@"subjectId"])
    {
        if ([value isEqualToNumber:@1])
        {
            self.subjectId = @"语文";
        }
        else if ([value isEqualToNumber:@2])
        {
            self.subjectId = @"数学";
        }
        else if ([value isEqualToNumber:@1])
        {
            self.subjectId = @"英语";
        }
        else
        {
        }
    } else if ([key isEqualToString:@"imgFileId"]) {
        
        self.ImgFID_Arr = [value componentsSeparatedByString:@","];
    } else if ([key isEqualToString:@"url"]) {
        
        NSString *Str = (NSString *)value;;
        if (Str.length > 0) {
        self.UrlArr = [value componentsSeparatedByString:@","];
        }
    } else if ([key isEqualToString:@"urlImg"]) {
        
        NSString *Str = (NSString *)value;;
        if (Str.length > 0) {
        self.UrlImgArr = [value componentsSeparatedByString:@","];
        }
    }
    else
    {
        [super setValue:value forKey:key];
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{}



- (NSMutableArray *)HaoChengJi_Arr
{
    if (!_HaoChengJi_Arr)
    {
        _HaoChengJi_Arr = [NSMutableArray array];
    }
    return _HaoChengJi_Arr;
}
- (NSMutableArray *)HaoSuYang_Arr
{
    if (!_HaoSuYang_Arr)
    {
        _HaoSuYang_Arr = [NSMutableArray array];
    }
    return _HaoSuYang_Arr;
}
- (NSMutableArray *)HaoXiGuan_Arr
{
    if (!_HaoXiGuan_Arr)
    {
        _HaoXiGuan_Arr = [NSMutableArray array];
    }
    return _HaoXiGuan_Arr;
}
- (NSMutableArray *)ImgF_Arr
{
    if (!_ImgF_Arr)
    {
        _ImgF_Arr = [NSMutableArray array];
    }
    return _ImgF_Arr;
}

-(NSMutableArray *)Videos_Arr {
    if (!_Videos_Arr) {
        _Videos_Arr = [NSMutableArray array];
    }
    return _Videos_Arr;
}


+ (BOOL)JudgeStrIsImagOrAudio:(NSString *)UrlStr
{

        NSString *Str = [UrlStr pathExtension];
        if ([Str isEqualToString:@"mp3"] ||
            [Str isEqualToString:@"ogg"] ||
            [Str isEqualToString:@"amr"])
        {
            return NO;
        }
        else
        {
            return YES;
        }

}
@end
